import { Entity, PrimaryGeneratedColumn, Column, Index } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

@Entity("character_mineral")
@ManualTimestamp()
@Index(["characterId", "itemId"]) // 按角色+物品聚合
export class CharacterMineralEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column("int", { name: "characterId", comment: "角色ID" })
  characterId!: number;

  @Column("int", { name: "itemId", comment: "矿石/矿盒 basic_items.id" })
  itemId!: number;

  @Column("int", { name: "num", default: 0, comment: "数量" })
  num!: number;

  @Column("int", { name: "status", default: 1, comment: "1正常，-1删除" })
  status!: number;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
  })
  updated_at!: Date | null;
}
